package com.hqyj.am.controller;

import com.hqyj.am.pojo.ResultVo;
import com.hqyj.am.pojo.Vacation;
import com.hqyj.am.service.IVacationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author rock
 */
@RestController
@RequestMapping("/vacation")
public class VacationController {
    @Resource
    IVacationService iVacationService;

    //单表-分页查询
    @GetMapping("/list1111111")//没用
    public ResultVo list(Vacation vacation){
        return iVacationService.queryByPage(vacation);
    }

    //多表-分页查询
    @GetMapping("/list")
    public ResultVo pageVacationAll(Vacation vacation){
        return iVacationService.pageVacationAll(vacation);
    }

    //员工(请假-出差)添加   -成功，但有重复数据（可以有）
    @GetMapping("/addVacation")
    public ResultVo AddVacation(Vacation vacation){
        System.out.println("vacation:"+vacation);
        return iVacationService.addVacation(vacation);
    }

    //员工状态(请假-出差)--修改   --验证成功
    @GetMapping("/updateVacation")
    public ResultVo updateVacation(Vacation vacation){
        return iVacationService.updateVacation(vacation);
    }

    //领导状态(请假-出差)--修改   --验证成功
    @GetMapping("/updateVacationState")
    public ResultVo updateVacationState(Vacation vacation){
        System.err.println("vacation:"+vacation);
        return iVacationService.updateVacationState(vacation);
    }

    //删除员工假条记录  ---验证成功
    @GetMapping("/deleteVacation")
    public ResultVo deleteVacation(Vacation vacation){
        return iVacationService.deleteVacation(vacation);
    }

    //根据员工姓名查询  --验证成功
    @GetMapping("/selectByUserName")
    public ResultVo selectByUserName(String userName){
        return iVacationService.selectByUserName(userName);
    }

    //查询单条记录  --验证成功
    @GetMapping("/selectByVacationId")
    public ResultVo selectByVacationId(Integer vacationId){
        return iVacationService.selectByVacationId(vacationId);
    }

    //根据员工 审核状态(未审核-已审核)查询
    @GetMapping("/selectByState")
    public ResultVo selectByState(String vacationState){
        System.out.println("vacationState=:"+vacationState);
        return iVacationService.selectByState(vacationState);
    }

    @GetMapping("/scheduleThing")
    public ResultVo scheduleThing(String vacationState){
        return iVacationService.scheduleThing(vacationState);
    }
}

